/**
 * 主题样式文件
 * 定义应用商店的浅色和深色主题样式
 * 使用CSS变量实现主题切换，支持动态主题切换
 */

/* ==================== Wails WebView 环境特殊优化 ==================== */

/* 确保在 Wails WebView 中所有弹窗都正确显示 */
.el-message-box__wrapper,
.el-dialog__wrapper,
.custom-dialog-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

.el-message-box,
.el-dialog,
.custom-dialog {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 1000000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
  border-radius: 16px !important;
  border: 1px solid var(--border-primary) !important;
  background: var(--bg-primary) !important;
}

.el-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 999998 !important;
  background-color: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

/* WebView 特定的样式修复 */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 确保在 WebView 中滚动条正确显示 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* WebView 中的动画优化 */
@media (prefers-reduced-motion: no-preference) {
  .custom-dialog {
    animation: dialogSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
}

/* Element Plus 子菜单深色主题修复 */
.el-sub-menu .el-menu--inline {
  background-color: transparent !important;
}

.el-sub-menu.is-opened .el-menu--inline {
  background-color: transparent !important;
}

.el-menu--inline .el-menu-item {
  background-color: transparent !important;
}

.el-sub-menu__title {
  background-color: transparent !important;
}

/* 强制所有弹窗在 WebView 中正确显示 */
body .el-message-box__wrapper,
body .el-dialog__wrapper,
body .custom-dialog-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

body .el-message-box,
body .el-dialog,
body .custom-dialog {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 1000000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
  border-radius: 16px !important;
  border: 1px solid var(--border-primary) !important;
  background: var(--bg-primary) !important;
}

/* 确保在 Wails 环境中所有弹窗都使用最高优先级 */
#app .el-message-box__wrapper,
#app .el-dialog__wrapper,
#app .custom-dialog-overlay {
  z-index: 999999 !important;
}

#app .el-message-box,
#app .el-dialog,
#app .custom-dialog {
  z-index: 1000000 !important;
}

/* ==================== 原有样式保持不变 ==================== */

/* 全局弹窗样式 - 确保在Wails应用中正确显示 */
.el-message-box__wrapper {
  z-index: 99999 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
}

.el-message-box {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 100000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.el-overlay {
  z-index: 99998 !important;
}

/* 卸载确认弹窗特殊样式 */
.uninstall-confirm-dialog .el-message-box__wrapper {
  z-index: 99999 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
}

.uninstall-confirm-dialog .el-message-box {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 100000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.uninstall-confirm-dialog .el-overlay {
  z-index: 99998 !important;
}

/* 确保所有 Element Plus 弹窗都正确显示 */
.el-dialog__wrapper {
  z-index: 99999 !important;
}

.el-dialog {
  z-index: 100000 !important;
}

/* 修复可能的定位问题 */
.el-message-box__wrapper[style*="position"] {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.el-message-box[style*="position"] {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
}

/* 强制修复弹窗定位问题 - 确保所有弹窗都显示为独立模态层 */
.el-message-box__wrapper,
.el-dialog__wrapper {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  z-index: 99999 !important;
}

.el-message-box,
.el-dialog {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 100000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border-radius: 8px !important;
}

.el-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 99998 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
}

/* 确保弹窗在所有情况下都正确显示 */
body .el-message-box__wrapper,
body .el-dialog__wrapper {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  z-index: 99999 !important;
}

body .el-message-box,
body .el-dialog {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: 100000 !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border-radius: 8px !important;
}

/* ==================== 主题变量定义 ==================== */

:root {
  /* 主色调 */
  --accent-primary: #3b82f6;
  --accent-secondary: #8b5cf6;
  --accent-hover: #2563eb;
  --accent-active: #1d4ed8;
  
  /* 背景色 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  /* 文字颜色 */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  
  /* 边框颜色 */
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  
  /* 阴影 */
  --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-heavy: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* 图标容器底色（确保浅色模式白色Logo可见） */
  --icon-bg: #e5e7eb; /* slate-200 */
}

/* 深色主题 */
.dark {
  /* 主色调 */
  --accent-primary: #60a5fa;
  --accent-secondary: #a78bfa;
  --accent-hover: #3b82f6;
  --accent-active: #2563eb;
  
  /* 背景色 */
  --bg-primary: #1e293b;
  --bg-secondary: #334155;
  --bg-tertiary: #475569;
  --bg-hover: #64748b;
  
  /* 文字颜色 */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  
  /* 边框颜色 */
  --border-primary: #475569;
  --border-secondary: #64748b;
  
  /* 阴影 */
  --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-heavy: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

  /* 深色主题图标容器底色（较深但不喧宾） */
  --icon-bg: #475569; /* slate-600 */
}

/* ==================== 全局样式 ==================== */

/* 基础样式重置 */
* {
  box-sizing: border-box;
}

html {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 应用容器 */
.app-container {
  display: flex;
  height: 100vh;
  background-color: var(--bg-secondary);
}

/* 主内容区域 */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background-color: var(--bg-secondary);
}

/* 页面标题区域 */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page-description {
  font-size: 16px;
  color: var(--text-secondary);
}

/* 卡片样式 */
.card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

/* 主要按钮样式 */
.btn-primary {
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* 次要按钮样式 */
.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background-color: var(--bg-secondary);
  border-color: var(--accent-primary);
}

/* 输入框样式 */
.input {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 8px 12px;
  transition: border-color 0.3s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ==================== 滚动条样式 ==================== */

/* Webkit浏览器滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ==================== 过渡动画 ==================== */

/* 淡入淡出动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* 滑动动画 */
.slide-enter-active,
.slide-leave-active {
  transition: transform 0.3s ease;
}

.slide-enter-from {
  transform: translateX(-100%);
}

.slide-leave-to {
  transform: translateX(100%);
}
